<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('BatMatch/index')}">对战列表</a></li>
        <li class="active"><a href="#">添加对战</a></li>
    </ul>
    <form action="{:url('BatMatch/save')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <tr>
                        <th width="150">比赛时间<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control js-bootstrap-datetime"  type="text" name="match_time"
                                   value="{:date('Y-m-d H:i:s',time())}">
                        </td>
                    </tr>
                    <tr>
                        <th width="150">投注结束时间<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control js-bootstrap-datetime"   type="text" name="bet_end_time"
                                   value="{:date('Y-m-d H:i:s',time())}">
                        </td>
                    </tr>
                    <tr>
                        <th width="150">联赛<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text"  name="lea_name"  required  placeholder="请输入联赛"/>
                        </td>
                    </tr>
                    <tr>
                        <th>类型<span class="form-required">*</span></th>
                        <td>
                            <select name="type" class="form-control" id="myselect" onchange="show(this[selectedIndex].value)">
                                <option value="0" >足球</option>
                                <option value="1" >篮球</option>
                                <option value="2" >电竞</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>主场球队<span class="form-required">*</span></th>
                        <td class="team">
                            <select name="team_main_id" class="form-control" id="team_main" >

                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>客场球队<span class="form-required">*</span></th>
                        <td class="team">
                            <select name="team_pass_id" class="form-control" id="team_pass" >

                            </select>
                        </td>
                    </tr>
<!--                    <tr>-->
<!--                        <th>是否推荐首页<span class="form-required"></span></th>-->
<!--                        <td>-->
<!--                            <select name="is_recommend" class="form-control">-->
<!--                                <option value="0" >否</option>-->
<!--                                <option value="1" >是</option>-->
<!--                            </select>-->
<!--                        </td>-->
<!--                    </tr>-->

                    <tr>
                        <th width="150">虚拟参与人数<span class="form-required"></span></th>
                        <td>
                            <input class="form-control" type="number" value="0" name="fake_num"   placeholder="请输入人数"/>
                        </td>
                    </tr>
                    <tr>
                        <th>猜胜负<span class="form-required"></span></th>
                        <td>
                            <span style="margin-right:20px;">主赔率</span>
                            <input class="form-control" type="number" min="0" name="v_main_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">平赔率</span>
                            <input class="form-control" type="number" min="0" name="v_middle_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">客赔率</span>
                            <input class="form-control" type="number" min="0" name="v_pass_odd"  style="width:100px;display:inline;">
                        </td>
                    </tr>
                    <tr>
                        <th>猜让球<span class="form-required"></span></th>
                        <td>
                            <span style="margin-right:20px;">主赔率</span>
                            <input class="form-control" type="number" min="0" name="g_main_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">让球名</span>
                            <input class="form-control" type="text" name="g_give_name"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">让球数</span>
                            <input class="form-control" type="number" name="g_give_num"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">客赔率</span>
                            <input class="form-control" type="number" min="0" name="g_pass_odd"  style="width:100px;display:inline;">
                        </td>
                    </tr>
                    <tr>
                        <th>猜大小<span class="form-required"></span></th>
                        <td>
                            <span style="margin-right:20px;">大赔率</span>
                            <input class="form-control" type="number" min="0" name="s_main_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">大小球</span>
                            <input class="form-control" type="number" min="0" name="s_size_num"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">小赔率</span>
                            <input class="form-control" type="number" min="0" name="s_pass_odd"  style="width:100px;display:inline;">
                        </td>
                    </tr>
                </table>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                        <a class="btn btn-default" href="{:url('BatMatch/index')}">{:lang('BACK')}</a>
                    </div>
                </div>

            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    getTeam($("#myselect").val())
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });
    
    function show(value) {
        getTeam(value);

    }

    function getTeam(value){
        $.ajax({
            url: '/admin/bat_match/getTeam',
            type: 'post',
            // 设置的是请求参数
            data: { type: value },
            dataType: 'json',
            // 用于设置响应体的类型 注意 跟 data 参数没关系！！！
            success: function (obj) {
                console.log(obj)
                //每次打开一个清空一下数据，否则后面的会一直追加下去
                $("#team_main").html('');
                $("#team_pass").html('');
                if ( ! obj ) {
                    return;
                }
                //开始遍历循环数据
                for ( i = 0, len = obj.length; i < len; i++ ) {
                    item = obj[ i ];
                    //把数据进行拼接，然后追加到页面去
                    var str = "<option value=" +item['id'] + ">" + item['team_name'] +"</option>"
                    //进行追加遍历到页面去
                    $("#team_main").append(str);
                    $("#team_pass").append(str);
                }
            }
        })
    }
</script>
</body>
</html>
